|
|
|
|
|
|
|
A bit of common sense is in order here. No valid string will have an address of 1. The source file in my test had 15 characters, not 4. Obviously, a handle in this case is not a pointer. |
|
|
|
|
|
|
|
|
Tempting though it was to surrender, my project editor was putting the pressure on to get this puzzle in, and I had already invested a lot of time on the problem. So I decided to take a close look at the contents of this so-called handle. I added the following code to the DoACopy function, bringing the program to the state you'll see in the solution directory in the FileOp2.vbp project (on the CD that comes with this book). The GetDataString function is a memory-viewing function in module errstring.bas and is defined in Tutorial 2, "Memory, Where It All Begins" (in Part III of this book). |
|
|
|
|
|
|
|
|
If sh.hNameMappings <> 0 Then
OriginalName = GetDataString(sh.hNameMappings, 16)
Debug.Print OriginalName
RtlMoveMemory NameMapping, ByVal sh.hNameMappings, _
Len(NameMapping)
OriginalName = GetDataString(NameMapping.pszNewPath, 16)
Debug.Print OriginalName |
|
|
|
|
|
|
|
|
The code is based on the premise that the only field in the memory pointed to by the hNameMappings structure that looks even remotely like a pointer is the data in the pszNewPath field. |
|
|
|
|
|
|
|
|
The first Debug statement showed the following data: |
|
|
|
|
|
|
|
|
01 00 00 00 FC 09 85 82 04 00 00 00 10 00 00 00 |
|
|
|
|
|